package com.zyc;

import com.zyc.bean.Student;
import com.zyc.dao.StudentDaoImpl;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.IllegalFormatCodePointException;
import java.util.List;
import java.util.Scanner;


public class test {
    @Test
 public void  test1() {

        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        StudentDaoImpl studentDao = context.getBean("studentDao", StudentDaoImpl.class);
       studentDao.addStudent(new Student("32323", "张三", "2018", "计算机", "男"));
       studentDao.addStudent(new Student("33333334", "李四", "2018", "计算机", "男"));
       studentDao.addStudent(new Student("33333335", "王五", "2018", "计算机", "男"));
       for (Student student : studentDao.selectAllStudent()){
           System.out.println(student);
       }
        Student updatedStudent = new Student("32323", "张三", "2019", "软件工程", "男");
        studentDao.updateSudent(updatedStudent);
      Student student2=   studentDao.selectStudent("32323");
        System.out.println("更新后的学生信息："+ student2);
        studentDao.selectAllStudent().forEach(System.out::println);
    }

}
